<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Records extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->lang->load('breadcrumb', 'estonian');
        $this->load->model('Record_model', 'RecordModel');
    }

    public function index($pool = false, $slug = false) {
        if (!$pool || !$slug) {
            redirect('records/50/men');
        }
        
        $pool = ($pool == 25) ? 25 : 50;
        $low_age = 0;
        $category = '';
        $high_age = 100;
        $gender = 'M';
        switch ($slug) {
            case 'men':
                $category = 'Mehed';
                break;
            case 'women':
                $category = 'Naised';
                $gender = 'F';
                break;
            case 'm-juniors':
                $category = 'Noormehed 17-18';
                $low_age = 17;
                $high_age = 18;

                break;
            case 'w-juniors':
                $category = 'Neiud 15-16';
                $gender = 'F';
                $low_age = 15;
                $high_age = 16;

                break;
            case 'm-youth':
                $category = 'Noored 15-16';
                $low_age = 15;
                $high_age = 16;

                break;
            case 'boys':
                $category = 'Poisid 14 ja nooremad';
                $low_age = 0;
                $high_age = 14;

                break;
            case 'girls':
                $category = 'Tüdrukud 14 ja nooremad';
                $gender = 'F';
                $low_age = 0;
                $high_age = 14;

                break;

            default:
                redirect('records/50/men');
                break;
        }
        $data['category_code'] = $slug;
        $data['pool'] = $pool;
        $data['category'] = $category;
        $data['records'] = $this->RecordModel->fetch_recrods_for_tuk($pool, $gender, $low_age, $high_age);
        $this->load->template('records', $data);
    }

}